home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / ST3FIX.ZIP / ST3FIX.ASM < prev    next >
Encoding:
Assembly Source File  |  1994-08-01  |  3.8 KB  |  192 lines

  1. ; ST3FIX - Code by Shades who is actualy pretty ashamed of this shit..
  2. ;
  3. ; Coded mainly as a fix for ST3 cause it wont reload the palette from
  4. ; st3.set <bah!>
  5. ;
  6. ; st3 SAVES just fine .. fucker wont load it tho! ;-(
  7. ;
  8. ; This code is hereby thrown into the public domain .. the author
  9. ; is not responsible for anything it may do to your system at all
  10. ;
  11.         ideal
  12.         dosseg
  13.         model small
  14.         stack 32
  15.         codeseg
  16.  
  17. PROC    Main
  18.         jmp far Install
  19. ENDP    Main
  20.  
  21. State   db 0
  22. OldInt9 dd 0
  23. filename db '\st3fix.pal',0
  24. buffer  db 0,0,0
  25.  
  26. PROC    Int9ISR
  27.         pushf
  28.         call [cs:OldInt9]
  29.         cmp [cs:State],0
  30.         je @@Check
  31. ExitIsr:iret
  32. @@Check:mov [cs:State], -1
  33.         push ax
  34.         push ds
  35.         mov ax, 40h
  36.         mov ds, ax
  37.         mov al, [ds:17h]
  38.         and al, 9h
  39.         cmp al, 9h
  40.         je LoadPal
  41.         mov al, [ds:17h]
  42.         and al, 5h
  43.         cmp al, 5h
  44.         je SavePal
  45.         pop ds
  46.         pop ax
  47.         mov [cs:State], 0
  48.         iret
  49. LoadPal:
  50.         push dx
  51.         push cx
  52.         push bx
  53.         call DosCheck
  54.         jc @@Er
  55.         mov ax, cs
  56.         mov ds, ax
  57.         assume ds:@code
  58.         mov ax, 3D00h
  59.         mov dx, offset Filename
  60.         int 21h
  61.         jc @@Er
  62.         mov bx, ax
  63.         mov cx, 256
  64. @@l1:   push cx
  65.         mov ah, 3Fh
  66.         mov cx, 3
  67.         mov dx, offset Buffer
  68.         int 21h
  69.         pop cx
  70.         mov dx, 3c8h
  71.         mov al, cl
  72.         out dx, al
  73.         inc dx
  74.         mov al, [cs:Buffer]
  75.         out dx, al
  76.         mov al, [cs:Buffer+1]
  77.         out dx, al
  78.         mov al, [cs:Buffer+2]
  79.         out dx, al
  80.         dec cx
  81.         jnz @@l1
  82.         mov ah, 3Eh
  83.         int 21h
  84. @@Er:
  85.         pop bx
  86.         pop cx
  87.         pop dx
  88.         pop ds
  89.         pop ax
  90.         mov [cs:State], 0
  91.         iret
  92. SavePal:
  93.         push dx
  94.         push cx
  95.         push bx
  96.         call DosCheck
  97.         jc @@Er2
  98.         mov ax, cs
  99.         mov ds, ax
  100.         assume ds:@code
  101.         mov ax, 3C00h
  102.         mov dx, offset Filename
  103.         sub cx, cx
  104.         int 21h
  105.         jc @@Er2
  106.         mov bx, ax
  107.         mov cx, 256
  108. @@l2:   push cx
  109.         mov dx, 3c7h
  110.         mov al, cl
  111.         out dx, al
  112.         inc dx
  113.         inc dx
  114.         in al, dx
  115.         mov [cs:Buffer], al
  116.         in al, dx
  117.         mov [cs:Buffer+1], al
  118.         in al, dx
  119.         mov [cs:Buffer+2], al
  120.         mov ah, 40h
  121.         mov cx, 3
  122.         mov dx, offset Buffer
  123.         int 21h
  124.         pop cx
  125.         dec cx
  126.         jnz @@l2
  127.         mov ah, 3Eh
  128.         int 21h
  129. @@er2:
  130.         pop bx
  131.         pop cx
  132.         pop dx
  133.         pop ds
  134.         pop ax
  135.         mov [cs:State], 0
  136.         iret
  137. ENDP    Int9ISR
  138.  
  139. PROC    DosCheck
  140.         push es
  141.         mov ah, 34h
  142.         int 21h
  143.         mov al, [es:bx]
  144.         pop es
  145.         cmp al, 0
  146.         jne UnSafe
  147.         clc
  148.         ret
  149. UnSafe: stc
  150.         ret
  151. ENDP    DosCheck
  152.  
  153. PROC    Install
  154.         mov ax, cs
  155.         mov ds, ax
  156.         mov es, ax
  157.         mov ah, 09h
  158.         mov dx, offset Message
  159.         int 21h
  160.         mov ax, 3509h
  161.         int 21h
  162.         mov [word CS:OldInt9], bx
  163.         mov [word cs:OldInt9+2], es
  164.         mov ax, 2509h
  165.         mov dx, offset Int9ISR
  166.         int 21h
  167.  
  168.         mov ah, 62h
  169.         int 21h
  170.         mov es, bx
  171.         xor ax, ax
  172.         xchg ax, [es:2Ch]
  173.         or ax, ax
  174.         jz NoEnv
  175.         mov es, ax
  176.         mov ah, 49h
  177.         int 21h
  178. NoEnv:
  179. ;        mov dx, offset Install
  180. ;        add dx, 0fh
  181. ;        mov cl, 4
  182. ;        shr dx, cl
  183.         mov ah, 31h
  184.         mov dx, 50
  185.         int 21h
  186.  
  187. ENDP    Install
  188.  
  189. Message db ' ST3 Palette Fixerupper - CTRL-RSHIFT to save a palette',13,10
  190.         db '                           ALT-RSHIFT to load a palette',13,10,'$'
  191.         end Main
  192.